package chap10collection.test19;

import java.util.*;

/**
 * @author zdl
 * @date 2024/12/18
 */
class Account{
    private static  long idCount =1;
    private Long id;
    private double balance;
    private String password;


    public Account() {
    }

    public Account( double balance, String password) {
        this.id = idCount++;
        this.balance = balance;
        this.password = password;
    }

    public static long getIdCount() {
        return idCount;
    }

    public static void setIdCount(long idCount) {
        Account.idCount = idCount;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String toString() {
        return "Account{id = " + id + ", balance = " + balance + ", password = " + password + "}";
    }
}
public class Demo19 {
    public static void main(String[] args) {
       /* Account account = new Account(10.00, "1234");
        Account account1 = new Account(10.00, "1234");
        System.out.println(account);
        System.out.println(account1);*/
        List<Account> list = new ArrayList<>();
        list.add(new Account(10.00, "1234"));
        list.add(new Account(15.00, "5678"));
        list.add(new Account(0.00, "1010"));
        System.out.println(list);
        Map<Long,Account> map = new HashMap<>();
        for (Account account : list) {
            map.put(account.getId(),account);
        }
        Set<Map.Entry<Long, Account>> entries = map.entrySet();
        for (Map.Entry<Long, Account> entry : entries) {
            System.out.println("id:"+entry.getKey()+"余额:"+entry.getValue().getBalance());
        }

    }
}
